/*
 *	Name:	emeta_exploit.h
 *
 *	Purpose:
 *	Include file containing the function prototypes used in the exploitation of enhanced
 *	metadata for purposes of calculating viewing and solar illumination angles. These
 *	functions operate on the EMETA data type defined in "emeta.h".
 */
#ifndef	_EMETA_EXPLOIT_H_
#define	_EMETA_EXPLOIT_H_

#include <limits.h>
#include "ias_odl.h"				/* IAS_OBJ_DESC definition                   */
#include "emeta.h"				/* Definition of EMETA structure             */

#define	SCA_OVERLAP	50			/* Max number of overlapping pixels          */

typedef struct EMETA_FRAME
{
    int		band;				/* Band number                               */
    int		nlines;				/* Number of image lines                     */
    int		nsamps;				/* Number of image samples                   */
    int		code;				/* Projection code (1 = UTM or 6 = PS)       */
    int		zone;				/* Projection zone number                    */
    double	ul_x;				/* Upper left corner X coordinate            */
    double	ul_y;                           /* Upper left corner Y coordinate            */
    double	pixsize;			/* Pixel size in meters                      */
} EMETA_FRAME;

int emeta_read(
    EMETA	*emeta,				/* Enhanced metadata structure to load       */
    const char	*emeta_filename );		/* Input file name to read                   */

int emeta_read_file_header(
    EMETA		*emeta,			/* Enhanced metadata structure to load       */
    IAS_OBJ_DESC        *emeta_odl );		/* Enhanced metadata ODL object              */

int emeta_read_projection(
    EMETA_SCENE_PROJ	*projection,		/* Projection structure to load              */
    IAS_OBJ_DESC        *emeta_odl );		/* Enhanced metadata ODL object              */

int emeta_read_ephemeris(
    EMETA		*emeta,			/* Enhanced metadata structure to load       */
    IAS_OBJ_DESC        *emeta_odl );		/* Enhanced metadata ODL object              */

int emeta_read_band_meta(
    EMETA_BAND		*band_emeta,		/* Enhanced metadata band structure to load  */
    IAS_OBJ_DESC        *emeta_odl );		/* Enhanced metadata ODL object              */

int emeta_angles_rpc(
    double		l1t_line,		/* Output space line coordinate              */
    double		l1t_samp,		/* Output space sample coordinate            */
    EMETA		*emeta,			/* Enhanced metadata structure               */
    int			band,			/* Current band number                       */
    double		*satang,		/* Satellite viewing zenith/azimuth angles   */
    double		*sunang );		/* Solar illumination zenith/azimuth angles  */

int emeta_find_scas(
    double		l1t_line,		/* Input L1T line                            */
    double		l1t_samp,		/* Input L1T sample                          */
    EMETA_BAND		*eband,			/* Enhanced metadata for current band        */
    double		*l1r_line,		/* Array of output L1R line numbers          */
    double		*l1r_samp );		/* Array of output L1R sample numbers        */

int emeta_write_angfile(
    char		*root_filename,		/* Output root file name                     */
    short		*sat_zn,		/* Array of satellite zenith angles          */
    short		*sat_az,		/* Array of satellite azimuth angles         */
    short		*sun_zn,		/* Array of solar zenith angles              */
    short		*sun_az,		/* Array of solar azimuth angles             */
    EMETA_FRAME		*frame );		/* Output image frame information            */

#endif
